package com.itlong.cloud.service.impl;

import com.itlong.cloud.enumerate.ecode.AppErrorCodeEnum;
import com.itlong.cloud.enumerate.oldapp.Code;
import com.itlong.cloud.network.tcp.mina.manage.SessionManage;
import com.itlong.cloud.service.IMinaService;
import org.springframework.stereotype.Service;

/**
* <desc>
*      mina业务处理接口实现类
* </desc>
*
* @createDate 2017/12/07
*/
@Service
public class MinaServiceImpl implements IMinaService {



    //一卡通TCP通讯对象
    private SessionManage getSessionManage() {
        return SessionManage.newInstance();
    }

    /**
     * <desc>
     *      发送消息到客户端
     * </desc>
     *
     * @param key
     * @param message 发送的消息
     * @return
     * @author Jiaqi.X
     * @createDate 2017/12/07
     */
    @Override
    public AppErrorCodeEnum sendMessage(String key, String message) {
        return this.getSessionManage().sendMessage(key, message);
    }

    /**
     * <desc>
     *     旧版APP_远程开门发送消息到一卡通
     * </desc>
     *
     * @param key
     * @param message
     * @return
     * @author Jiaqi.X
     * @createDate 2017/12/07
     */
    @Override
    public Code oldSendMessage(String key, String message) {
        return this.getSessionManage().oldSendMessage(key, message);
    }
}
